<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>06.输入内容防抖处理</title>
  </head>
  <body>
    <div id="app">
      {{ fullName }}

      <div>msg: <input v-model="msg" /></div>
    </div>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.14/vue.js"></script>
    <script>
      new Vue({
        el: "#app",
        data: {
          msg: "zyh",
          fullName: "谁是最：",
        },

        watch: {
          msg: function (val) {
            clearTimeout(this.timer);
            this.timer = setTimeout(() => {
              this.fullName = this.fullName + val;
            }, 500);
          },
        },
      });
    </script>
  </body>
</html>
